package net.janeluo.rs.module;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import net.janeluo.rs.entity.RS_SymNotice;
import net.janeluo.rs.entity.RS_User;
import net.janeluo.rs.service.SymNoticeManagerService;

import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

/**
 * 系统通知模块
 * 
 * @author DLK)JaneLuo
 * @version 1.0.0
 */
@IocBean
@At("/")
public class SymNoticeManagerModule {
    private static final Log log = Logs.getLog(SymNoticeManagerModule.class);
    
    @Inject
    private SymNoticeManagerService symNoticeManagerService;
    
    /**
     * 初始化显示通知管理首页
     */
    @At("SymNoticeManager")
    @Ok("jsp:views.SymNoticeManager")
    public List<RS_SymNotice> initSymNotice(HttpServletRequest req, @Param("sntitle") String sntitle){
        log.debug("--------------- 查询用户列表开始 ----------------");
        req.getSession().setAttribute("menuName", "SymNoticeManager");
        List<RS_SymNotice> noticesList = symNoticeManagerService.getNoticesList(sntitle);
        log.debug("--------------- 查询用户列表结束 ----------------");
        return noticesList;
    }
    
    @At("AddNotice")
    @Ok("->:/SymNoticeManager.nut?flag=1")
    public void addSymNotice(HttpServletRequest req, @Param("..") RS_SymNotice notice) {
        log.debug("============== 添加通知处理开始 ==============");
        RS_User user = (RS_User) req.getSession().getAttribute("user");
        notice.setUserid(user.getUserid());
        notice.setUserName(user.getUserName());
        symNoticeManagerService.insertNotice(notice);
        
        log.debug("============== 添加通知处理结束 ==============");
    }
    

    /**
     * 删除通知
     */
    @At("DeleteSymNotice")
    @Ok("->:/SymNoticeManager.nut")
    public void deleteUser(@Param("snids") Integer[] snidarr) {
        log.debug("--------------- 删除用户开始 ----------------");
        
        symNoticeManagerService.deleteNotices(snidarr);
        
        log.debug("--------------- 删除用户结束 ----------------");
    }
}
